package com.awesome.blog.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.awesome.blog.entity.Category;
import com.awesome.blog.service.CategoryService;
import com.google.gson.Gson;

@Controller
@CrossOrigin
public class CategoryController {
	@Autowired
	public CategoryService categoryService;
	@ResponseBody 
	@RequestMapping(value="/getCate",produces="text/json;charset=UTF-8",method= RequestMethod.GET)
	public String selectAll() {
		//System.out.println(1);
		List<Category> list = categoryService.selectAll();
		//System.out.println(list);
		Gson gson=new Gson();
		String gson1=gson.toJson(list);
		return gson1;
	}
}
